package appconfig

import (
	"github.com/spf13/viper"
	"github.com/zeromicro/go-zero/core/logx"
)

type ViperData struct {
	Mysql struct {
		Username string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Addr     string
		Password string
		DB       int
	}
}

var Conf ViperData

func GetViperData() {
	viper.SetConfigFile("../api/appconfig/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("配置文件读取失败")
	}
	err = viper.Unmarshal(&Conf)
	if err != nil {
		panic("配置文件解析失败")
	}
	logx.Info(Conf)

}
